#ifndef _OAUTH20CREDENTIALS_HPP_
#define _OAUTH20CREDENTIALS_HPP_

#include "jhdefs.hpp"
#include "net/HTTPRequest.hpp"

#include <string>

NET_NAMESPACE_BEGIN

class COAuth20Credentials
{
public:
	COAuth20Credentials();
	explicit COAuth20Credentials(const std::string& bearerToken);
	COAuth20Credentials(const std::string& bearerToken, const std::string& scheme);
	explicit COAuth20Credentials(const CHTTPRequest& request);
	COAuth20Credentials(const CHTTPRequest& request, const std::string& scheme);
	~COAuth20Credentials();

	void setBearerToken(const std::string& bearerToken);
	const std::string& getBearerToken() const;

	void setScheme(const std::string& scheme);
	const std::string& getScheme() const;

	void authenticate(CHTTPRequest& request);

	static const std::string SCHEME;

protected:
	void extractBearerToken(const CHTTPRequest& request);

private:
	COAuth20Credentials(const COAuth20Credentials&);
	COAuth20Credentials& operator = (const COAuth20Credentials&);

	std::string m_bearerToken;
	std::string m_scheme;
};

NET_NAMESPACE_END

#endif